package br.agenda.crud.db;

import java.sql.*;

public class ConexaoMySQL {
	 public static Statement conectar() {  
	        try {  
	            String driverName = "com.mysql.jdbc.Driver";                          
	            Class.forName(driverName);  
	            String serverName = "localhost";    
	            String mydatabase ="agendacrud";       
	            String url = "jdbc:mysql://" + serverName + "/" + mydatabase;  
	            String username = "root";            
	            String password = "1234";     
	            Connection connection = DriverManager.getConnection(url, username, password);
	            Statement stmt = connection.createStatement();
	            return stmt;  
	        }  catch (ClassNotFoundException e) { 
	            System.out.println("O driver expecificado nao foi encontrado.");  
	            return null;  
	        } catch (SQLException e) {  
	            System.out.println("Nao foi possivel conectar ao Banco de Dados.");  
	            return null;  
	        }
	 }
}